//
// CPSZone.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CVector;
import org.ryzom.nel.misc.IStream;

public class CPSZone extends CPSTargetLocatedBindable {
  private long swigCPtr;

  public CPSZone(long cPtr, boolean cMemoryOwn) {
    super(nel3dJNI.CPSZone_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(CPSZone obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CPSZone(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public long getType() {
    return nel3dJNI.CPSZone_getType(swigCPtr, this);
  }

  public long getPriority() {
    return nel3dJNI.CPSZone_getPriority(swigCPtr, this);
  }

  public void step(TPSProcessPass pass) {
    nel3dJNI.CPSZone_step(swigCPtr, this, pass.swigValue());
  }

  public void show() {
    nel3dJNI.CPSZone_show(swigCPtr, this);
  }

  public void attachTarget(CPSLocated ptr) {
    nel3dJNI.CPSZone_attachTarget(swigCPtr, this, CPSLocated.getCPtr(ptr), ptr);
  }

  public void serial(IStream f) {
    nel3dJNI.CPSZone_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public void releaseTargetRsc(CPSLocated target) {
    nel3dJNI.CPSZone_releaseTargetRsc(swigCPtr, this, CPSLocated.getCPtr(target), target);
  }

  public void setBounceFactor(float bounceFactor) {
    nel3dJNI.CPSZone_setBounceFactor(swigCPtr, this, bounceFactor);
  }

  public float getBounceFactor() {
    return nel3dJNI.CPSZone_getBounceFactor(swigCPtr, this);
  }

  public void setCollisionBehaviour(CPSZone.TCollisionBehaviour behaviour) {
    nel3dJNI.CPSZone_setCollisionBehaviour(swigCPtr, this, behaviour.swigValue());
  }

  public CPSZone.TCollisionBehaviour getCollisionBehaviour() {
    return CPSZone.TCollisionBehaviour.swigToEnum(nel3dJNI.CPSZone_getCollisionBehaviour(swigCPtr, this));
  }

  public void computeCollisions(CPSLocated target, long firstInstanceIndex, CVector posBefore, CVector posAfter) {
    nel3dJNI.CPSZone_computeCollisions(swigCPtr, this, CPSLocated.getCPtr(target), target, firstInstanceIndex, CVector.getCPtr(posBefore), posBefore, CVector.getCPtr(posAfter), posAfter);
  }

  public final static class TCollisionBehaviour {
    public final static TCollisionBehaviour bounce = new TCollisionBehaviour("bounce", nel3dJNI.CPSZone_bounce_get());
    public final static TCollisionBehaviour destroy = new TCollisionBehaviour("destroy", nel3dJNI.CPSZone_destroy_get());

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TCollisionBehaviour swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TCollisionBehaviour.class + " with value " + swigValue);
    }

    private TCollisionBehaviour(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TCollisionBehaviour(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TCollisionBehaviour(String swigName, TCollisionBehaviour swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TCollisionBehaviour[] swigValues = { bounce, destroy };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
